package com.lauroc.dept.domain;

import com.lauroc.basic.utils.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@ApiModel(value = "com.lauroc.dept.domain", description = "一个对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_department")
public class Department extends BaseTreeNode<Department> {

    @Id
    @ApiModelProperty(value = "主键ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(value = "部门编号")
    @Size(min = 3,max = 8,message = "请输入3到8位的数")
    private String sn;

    @ApiModelProperty(value = "部门名称")
    @NotBlank(message = "部门名称不能为空")
    private String name;

    private Integer state;

    @Column(name = "manager_id")
    private Long managerId;

    @Column(name = "parent_id")
    private Long parentId;

    @Column(name = "dir_path")
    private String dirPath;

    //部门经理的名字
    @Transient
    private String managerName;

    //上级部门名称
    @Transient
    private String parentName;

    //
    @Transient
    private Long[] parentIds;

}
